import prompt from '@system.prompt';
import http from '@ohos.net.http';
export default {
    data: {
        // 3.手部震颤
        vals31:"-",
        vals32:"-",
        vals33:"-",
        num: 3,
        return_result: {
        },
    },

    start_detection(){
        // 创建一个http请求
        let httpRequest = http.createHttp();
        let url = "http://120.46.171.116:8081/get_specified_accel_data";
        httpRequest.request(url, {
            method: 'POST',
            extraData: {
                "account": "15565988801",
                "time": "20230222225333",
            },
        }, (err, data)=> {  // 判断是否请求成功
            if (!err) {  // 请求成功
                this.return_result = JSON.parse(data.result);  //JSON.parse(字符串)：将字符串转换成json数据格式
                this.vals31 = this.return_result.results.last_update;  //使用json赋值变量
                this.vals32 = this.return_result.results.frequency;
                this.vals33 = this.return_result.results.frelevel;
                console.info("获取数据失败："+data.result)
            } else {  // 请求失败
                var winfo = JSON.parse(data.result);
                console.info("获取数据失败："+winfo)
                prompt.showToast({
                    message: winfo,
                    duration: 3000,
                });
            }
        })
    }
}
